from RDF import Uri, Storage, Model, Parser, Statement
from django.db.transaction import commit_on_success
from django.http import Http404, HttpResponse
from duetopia.envisat.models import Product

@commit_on_success
def import_rdf(request):
	print "hello"

	dcid = Uri("http://purl.org/dc/elements/1.1/identifier")
        storage = Storage(storage_name="memory", name="memory", options_string="")
        model = Model(storage)
        parser = Parser()

        parser.parse_string_into_model(model, request.raw_post_data,
				       "http://www.example.com/")
	
	for obj in Product.objects.make_all_from_rdf_model(model):
		print "import_rdf: created", obj

	return HttpResponse("OK")
